import * as api from '@/api/user.js'

export default {
    namespaced: true,
    state: {
        profile: {
            name: '请登录',
        },
        info: {

        },
    },
    mutations: {
        SET_USER_PROFILE(state, newValue) {
            state.profile = newValue
        },
        SET_USER_INFO(state, newValue) {
            state.info = newValue
        },
    },
    actions: {
        async updateUserProfile(context) {
            const res = await api.getUserProfile()
            context.commit('SET_USER_PROFILE', res.data.data)
        },
        async updateUserInfo(context) {
            const res = await api.getUserInfo()
            context.commit('SET_USER_INFO', res.data.data)
        },
    },
}